package com.javaweb.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.javaweb.admin.entity.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface GSPMapper extends BaseMapper<POCheck> {
    /**
     * 获取推送NC药品验收记录
     * @return
     */
    @Select("select * from v_gsp_pocheck left join t_gsp_pocheck_status on v_gsp_pocheck.pk_pocheck=t_gsp_pocheck_status.pocheck where t_gsp_pocheck_status.pocheck is null")
    List<POCheck> getList();

    @Insert(" insert into t_gsp_pocheck_status (pocheck) values (#{pkPocheck})")
    void updateStatus(String pkPocheck);

    @Select("")
    List<PurchaseReturn> getPurchaseReturnList();

    /**
     * 获取推送NC出库复核记录
     * @return
     */
    @Select("select * from v_gsp_outcheck left join t_gsp_outcheck_status on v_gsp_outcheck.Inspectionlot=t_gsp_outcheck_status.Inspectionlot where t_gsp_outcheck_status.Inspectionlot is null ")
    List<OutCheck> getOutCheckList();

    /**
     * 获取推送NC退货药品验收记录
     * @return
     */
    @Select("select * from v_gsp_sale_returncheck left join t_gsp_sale_returncheck_status on v_gsp_sale_returncheck.pk_srcheck=t_gsp_sale_returncheck_status.srcheck where t_gsp_sale_returncheck_status.srcheck is null and v_gsp_sale_returncheck.storename<>'1012'")
    List<SaleReturnCheck> getSaleReturnCheckList();

    @Insert(" insert into t_gsp_sale_returncheck_status (srcheck) values (#{pkSrcheck})")
    void updateSrcheckStatus(String pkSrcheck);

    @Insert("insert into t_gsp_outcheck_status (Inspectionlot) values (#{Inspectionlot});")
    void updateOutCheckStatus(String inspectionlot);

    @Insert("")
    void updatePurchaseReturenStatus();

    /**
     * 获取推送NC药品拒收记录
     * @return
     */
    @Select("select * from v_gsp_rgr left join t_gsp_rgr_status on v_gsp_rgr.pk_rgr=t_gsp_rgr_status.rgr where t_gsp_rgr_status.rgr is null ")
    List<Rgr> getRgrList();

    @Insert("insert into t_gsp_rgr_status (rgr) values (#{pkRgr})")
    void updateRgrStatus(String pkRgr);

    /**
     * 获取推送NC药品收货记录
     * @return
     */
    @Select("select * from v_gsp_purchasewe left join t_gsp_purchasewe_status on v_gsp_purchasewe.pk_we=t_gsp_purchasewe_status.we where t_gsp_purchasewe_status.we is null ")
    List<Purchasewe> getPurchaseweList();
    @Insert("insert into t_gsp_purchasewe_status (we) values (#{pkWe})")
    void updatePurchaseweStatus(String pkWe);
}
